import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

const path = require('path')

// https://vitejs.dev/config/
export default defineConfig({
  build: {
    outDir: 'fund',
  },
  server: {
    proxy: {
      '/api': {
        target: 'http://fund.eastmoney.com',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/areas_v3': {
        target: 'https://geo.datav.aliyun.com',
        changeOrigin: true,
        headers: {
          // referer: 'https://geo.datav.aliyun.com',
          referer: '',
        }
      },
    },
  },
  plugins: [vue()],
  optimizeDeps: {
    include: [
      'moment',
      // "echarts",
      // "axios",
      // "mockjs",
    ]
  },
  resolve: {
    alias: {
      '/@': path.resolve(__dirname, 'src'),
    },
  },
  css: {
    preprocessorOptions: {
      less: {
        javascriptEnabled: true,
      }
    },
  },
})
